import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { ResouceConst } from "../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../resource/ImagesConst";
import { SendBlessListCellRenderer } from "./SendBlessListCellRenderer";
import { PageSelecter } from "../common/pageSelect/PageSelecter";
import { Cache } from "../../cache/Cache";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { GameConst } from "../../../component/gconst/GameConst";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { GLabel } from "../../../../com/mui/controls/GLabel";
type int = number;
//class FriendBlessSendPanel
    
    export  class FriendBlessSendPanel extends BaseWindow
    {
        constructor()
        {
            super();
            this.setSize(400, 355);
            title = Language.getString(69423);
            this.titleHeight = 26;
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc2=null;
            super.createChildren();
            ObjCreate.createBg(16, 38, 363, 305, this);
            var loc1=0;
            while (loc1 < 8) 
            {
                loc2 = ResouceConst.getScaleBitmap(ImagesConst.SplitLine);
                loc2.x = 20;
                loc2.y = 66 + loc1 * 30;
                loc2.width = 350;
                loc2.height = 2;
                this.addChild(loc2);
                ++loc1;
            }
            ObjCreate.createLabel(Language.getString(69435), 20, 45, 120, 20, flash.text.TextFormatAlign.CENTER, this, true, 16711368);
            ObjCreate.createLabel(Language.getString(69436), 140, 45, 55, 20, flash.text.TextFormatAlign.CENTER, this, true, 16711368);
            ObjCreate.createLabel(Language.getString(69437), 195, 45, 55, 20, flash.text.TextFormatAlign.CENTER, this, true, 16711368);
            ObjCreate.createLabel(Language.getString(69438), 250, 45, 55, 20, flash.text.TextFormatAlign.CENTER, this, true, 16711368);
            ObjCreate.createLabel(Language.getString(69439), 305, 45, 70, 20, flash.text.TextFormatAlign.CENTER, this, true, 16711368);
            this._sendBlessList = ObjCreate.createTileList(20, 63, 470, 215, this);
            this._sendBlessList.columnWidth = 470;
            this._sendBlessList.rowHeight = 30;
            this._sendBlessList.setStyle("cellRenderer", SendBlessListCellRenderer);
            this._pageBtn = ObjCreate.createPageSelecter(140, 282, this);
            this._pageBtn.mode = PageSelecter.CompleteMode;
            this._pageBtn.addEventListener(flash.events.Event.CHANGE, this.updateBlessList);
            this._countLabel = ObjCreate.createLabel("", 0, 304, 400, 20, flash.text.TextFormatAlign.CENTER, this, true, 16776960);
            ObjCreate.createLabel(Language.getString(69440), 0, 322, 400, 20, flash.text.TextFormatAlign.CENTER, this, true, 16776960);
            return;
        }

        public updateBlessList(arg1: Object /* flash.events.Event */=null): void
        {
            var loc1=Cache.instance.friendBless.blessQueue;
            if (loc1.length == 0) 
            {
                this.hide();
                return;
            }
            this._pageBtn.maxPage = Math.ceil(loc1.length / this._pagesize);
            var loc2=(this._pageBtn.currentPage - 1) * this._pagesize;
            var loc3=this._pageBtn.currentPage * this._pagesize > loc1.length ? loc1.length : this._pageBtn.currentPage * this._pagesize;
            var loc4=loc1.slice(loc2, loc3);
            this._sendBlessList.dataProvider = new DataProvider(loc4);
            return;
        }

        public updateBlessNum(): void
        {
            this._countLabel.htmlText = HTMLUtil.addColor(Language.getStringByParam(69441, Cache.instance.friendBless.sendBlessCount, GameConst.FriendBlessMaxCount), "#FFFF00");
            return;
        }

        /* internal */ /* var */_sendBlessList: GTileList;

        /* internal */ /* var */_pageBtn: PageSelecter;

        /* internal */ /* var */_pagesize: int=7;

        /* internal */ /* var */_countLabel: GLabel;
    }
